#include<iostream>
using namespace std;
const int N = 1e5 + 10;
int arr[N];
int n, q;
int main()
{
	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	int x;
	while (q--) {
		cin >> x;
		int l = 0, r = n - 1;
		while (l < r) {
			int mid = l + r >> 1;
			if (arr[mid] >= x) {
				r = mid;
			}
			else {
				l = mid + 1;
			}
		}
		if (arr[l] == x) {
			cout << l << " ";
			r = n - 1;
			while (l < r) {
				int mid = l + r + 1 >> 1;
				if (arr[mid] <= x) {
					l = mid;
				}
				else {
					r = mid - 1;
				}
			}
			cout << r << endl;
		}
		else {
			cout << "-1 -1" << endl;
		}
	}
	return 0;
}